<template>
  <view class="container">
    <uni-nav-bar
      :border="false"
      statusBar
      title="工单详情"
      color="#ffffff"
      left-icon="left"
      backgroundColor="transparent"
      @clickLeft="onBack"
    >
    </uni-nav-bar>

    <view class="box">
      <view class="mainBox">
        <view class="id">{{ query?.name || '工单详情' }}</view>
        <!-- <view class="val">{{ data.deptName }}<text>{{ data.applicationUser }}</text></view> -->
        <!-- <view class="status">状态{{data.orderStatus == 2 ? '已完成' : '未完成'}}</view> -->
      </view>
      <view class="infoBox">
        <view class="item">
          <text class="name">申请人</text>
          <text class="val"
            >{{ data?.applicationUser
            }}{{ data?.deptName ? `[${data?.deptName}]` : '' }}</text
          >
        </view>
        <view class="item">
          <text class="name">申请人电话</text>
          <text class="val">{{ data?.applicationPhone }}</text>
        </view>
        <view class="item">
          <text class="name">申请时间</text>
          <text class="val">{{ data?.applicationDate }}</text>
        </view>
        <view class="item">
          <text class="name">申请事由</text>
          <text class="val">{{ data?.applicationReason }}</text>
        </view>
        <view class="item">
          <text class="name">物品所属人</text>
          <text class="val">{{ data?.goodsOwnPerson }}</text>
        </view>
        <view class="item">
          <text class="name">物品所属单位</text>
          <text class="val">{{ data?.goodsOwnUnit }}</text>
        </view>
        <view class="item">
          <text class="name">司机信息</text>
          <text class="val"
            >{{ data?.driverName }}{{ `(TEL: ${data?.driverPhone})` }}</text
          >
        </view>
        <view class="item">
          <text class="name">车牌号</text>
          <text class="val">{{ data?.carNumber }}</text>
        </view>
        <view class="item">
          <text class="name">描述</text>
          <text class="val">{{ data?.described }}</text>
        </view>
        <view class="item">
          <text class="name">放行描述</text>
          <text class="val">{{ data?.releaseDescribed }}</text>
        </view>
        <view class="item">
          <text class="name">附件</text>
          <text class="val">
            <img
              v-for="(item, i) in data.ossurl"
              :key="i"
              :src="item?.url"
              style="
                width: 100rpx;
                height: 100rpx;
                background: #aaa;
                border-radius: 10rpx;
              "
              @click="onPreviewImg(data.ossurl, i)"
            />
          </text>
        </view>
      </view>
      <view-audit :query="query" />
    </view>
  </view>
</template>

<script>
import { getOssList } from '@/api/index';
import { getPassPermitDetail } from '@/api/workOrder';
import ViewAudit from './viewAudit.vue';
export default {
  components: {
    ViewAudit,
  },
  data() {
    return {
      data: {},
      query: {},
    };
  },
  onLoad(query) {
    this.query = query;
    this.getData();
  },
  methods: {
    getData() {
      getPassPermitDetail(this.query.businessKey).then((res) => {
        this.data = res.data;
        if (res.data.ossIdArrStr) {
          getOssList(res.data.ossIdArrStr).then((res) => {
            this.data.ossurl = res.data;
          });
        }
      });
    },
    // 预览图片
    onPreviewImg(url, i) {
      uni.previewImage({
        current: i,
        urls: url.map((item) => item.url),
      });
    },
    // 跳转页面
    onLocation(url) {
      uni.navigateTo({
        url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  min-height: calc(100vh - 160rpx);
  padding-bottom: calc(
    var(--window-bottom) + constant(safe-area-inset-bottom) + 160rpx
  );
  padding-bottom: calc(
    var(--window-bottom) + env(safe-area-inset-bottom) + 160rpx
  );
  background: linear-gradient(180deg, #d7e4fd 0%, #fff 50%);
  background-repeat: no-repeat;
  background-size: 100% auto;
  position: relative;
  .box {
    position: relative;
    margin: 50rpx 36rpx 0;
    padding: 24rpx;
    background: #ffffff;
    border-radius: 12rpx;
    box-shadow: 0 0 30rpx 0 #ccc;
    .mainBox {
      text-align: center;
      padding: 40rpx 0;
      line-height: 1;

      .id {
        font-size: 38rpx;
        font-weight: bold;
        color: #4288ff;
        padding-bottom: 40rpx;
      }

      .val {
        font-size: 40rpx;
        font-weight: 800;
        color: #ff884d;
        padding-bottom: 27rpx;

        text {
          font-size: 30rpx;
          margin-left: 10rpx;
        }
      }

      .status {
        font-size: 26rpx;
        font-weight: 500;
        color: #555555;
      }
    }
    .infoBox {
      .item {
        font-size: 30rpx;
        font-weight: 500;
        padding: 22rpx 12rpx;
        display: flex;
        justify-content: space-between;
        border-bottom: 2rpx solid #eaeaea;
        &:last-child {
          border-bottom: 0;
        }
        .name {
          color: #989898;
        }

        .val {
          width: 60%;
          color: #333;
          text-align: right;
          word-break: break-all;
        }
      }
    }
  }
  .myLabel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .star {
      color: #dd524d;
    }
  }
}
</style>
